<?php

use yii\db\Migration;

/**
 * Handles the creation of table `project`.
 */
class m170717_095415_create_project_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }

        $this->createTable('{{%project}}', [
            'id' => $this->primaryKey()->comment('自增ID'),
            'project_name' => $this->string(255)->notNull()->comment('项目名称'),
            'eqip_name' => $this->string(255)->notNull()->comment('设备名称'),
            'add_user_name' => $this->string(255)->notNull()->comment('添加项目人'),
            'content' => $this->string(255)->notNull()->comment('内容'),
            'status' => $this->smallInteger()->notNull()->defaultValue(0)->comment('类型:0未过期1已过期'),
            'created_at' => $this->integer()->notNull()->comment('创建时间'),
            'updated_at' => $this->integer()->notNull()->comment('结束时间')
        ], $tableOptions);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('project');
    }
}
